package com.controllers;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
* Created by zhuqiang on 2015/6/23 0023.
        */
@Configuration
@EnableWebMvc
@EnableWebSocket//开启websocket
public class WebSocketConfig implements WebSocketConfigurer {
    public static WebSocketHander webSocketHander = new WebSocketHander();
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(webSocketHander,"/sockjs/echo").addInterceptors(new HandshakeInterceptor()).withSockJS(); //不支持websocket的访问链接
        registry.addHandler(webSocketHander,"/echo").addInterceptors(new HandshakeInterceptor()); //支持websocket 的访问链接
    }
}